var Action = require("../apiaction");
var Utility = require("../Utility/utility.js");
exports.workerAPI = function(router){

    //获取工人列表
    router.all('/worker/getworkerlist',function(req,res){

        var params ={mobile: req.param("mobile"),real_name: req.param("real_name"),idcard: req.param("idcard"),worker_num:req.param("worker_num")};
        params = Utility.get_list_page_size_param(req,params);

        Action.send(req, res,"/worker/getworkerlist",params,function(res,data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //获取工人申请列表
    router.all('/worker/getworkerrequestlist',function(req,res){

        var params ={mobile: req.param("mobile"),status: req.param("status")};
        params = Utility.get_list_page_size_param(req,params);

        Action.send(req, res,"/worker/getworkerrequestlist",params,function(res,data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //同意申请
    router.all('/worker/AcceptRequest',function(req,res){

        var params ={request_id: req.param("request_id"),reason: req.param("reason")};
        params = Utility.get_list_page_size_param(req,params);

        Action.send(req, res,"/worker/AcceptRequest",params,function(res,data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //拒绝申请
    router.all('/worker/denyRequest',function(req,res){

        var params ={request_id: req.param("request_id"),reason: req.param("reason")};
        params = Utility.get_list_page_size_param(req,params);

        Action.send(req, res,"/worker/denyRequest",params,function(res,data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //工人请求log
    router.all('/worker/getRequestLogList',function(req,res){

        var params ={request_id: req.param("request_id")};
        params = Utility.get_list_page_size_param(req,params);

        Action.send(req, res,"/worker/getRequestLogList",params,function(res,data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //轮播图管理
    router.all('/workerCarosel/GetCaroselList',function(req,res){

        var params ={};
        params = Utility.get_list_page_size_param(req,params);

        Action.send(req, res,"/workerCarosel/GetCaroselList",params,function(res,data) {
            res.status(200).json(JSON.parse(data));
        });
    });

      //添加轮播图
    router.all('/workerCarosel/AddCarosel',function(req,res){

        var params ={pic_url: req.param("pic_url"),title: req.param("title"),link_url: req.param("link_url")};
        params = Utility.get_list_page_size_param(req,params);

        Action.send(req, res,"/workerCarosel/AddCarosel",params,function(res,data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //删除轮播图
    router.all('/workerCarosel/DeleteCarosel',function(req,res){

        var params ={pic_id: req.param("pic_id")};
        params = Utility.get_list_page_size_param(req,params);

        Action.send(req, res,"/workerCarosel/DeleteCarosel",params,function(res,data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //轮播图
    router.all('/workerCarosel/UpdateCarosel',function(req,res){

        var params ={pic_url: req.param("pic_url"),title: req.param("title"),link_url: req.param("link_url"),pic_id: req.param("pic_id")};
        params = Utility.get_list_page_size_param(req,params);

        Action.send(req, res,"/workerCarosel/UpdateCarosel",params,function(res,data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //案例列表
    router.all('/workerCaselist/GetList',function(req,res){

        var params ={};
        params = Utility.get_list_page_size_param(req,params);

        Action.send(req, res,"/workerCaselist/GetList",params,function(res,data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    router.all('/workerCaselist/AddCase',function(req,res){


        //效果图

        var design_piclist = "";

        design_piclist = Utility.mergeParam(req,design_piclist,"design1");
        design_piclist = Utility.mergeParam(req,design_piclist,"design2");
        design_piclist = Utility.mergeParam(req,design_piclist,"design3");
        design_piclist = Utility.mergeParam(req,design_piclist,"design4");
        design_piclist = Utility.mergeParam(req,design_piclist,"design5");
        design_piclist = Utility.mergeParam(req,design_piclist,"design6");


        //施工图

        var construction_piclist = "";

        construction_piclist = Utility.mergeParam(req,construction_piclist,"construct1");
        construction_piclist = Utility.mergeParam(req,construction_piclist,"construct2");
        construction_piclist = Utility.mergeParam(req,construction_piclist,"construct3");
        construction_piclist = Utility.mergeParam(req,construction_piclist,"construct4");
        construction_piclist = Utility.mergeParam(req,construction_piclist,"construct5");
        construction_piclist = Utility.mergeParam(req,construction_piclist,"construct6");





        var params ={type_name: req.param("type_name"),worker_name: req.param("worker_name"),worker_avatar: req.param("worker_avatar"),
            price: req.param("price"),status: req.param("status"),start_time: req.param("start_time"),
            end_time: req.param("end_time"),publish_time: req.param("publish_time"),address: req.param("address"),
            square: req.param("square"),amount: req.param("amount"),design_piclist: design_piclist,
            construction_piclist:construction_piclist

        };
        params = Utility.get_list_page_size_param(req,params);

        Action.send(req, res,"/workerCaselist/AddCase",params,function(res,data) {
            res.status(200).json(JSON.parse(data));
        });
    });


    //删除案例
    router.all('/workerCaselist/Delete',function(req,res){

        var params ={obj_id: req.param("obj_id")};
        params = Utility.get_list_page_size_param(req,params);

        Action.send(req, res,"/workerCaselist/Delete",params,function(res,data) {
            res.status(200).json(JSON.parse(data));
        });
    });


    router.all('/workerCaselist/Update',function(req,res){


        //效果图

        var design_piclist = "";

        design_piclist = Utility.mergeParam(req,design_piclist,"design1");
        design_piclist = Utility.mergeParam(req,design_piclist,"design2");
        design_piclist = Utility.mergeParam(req,design_piclist,"design3");
        design_piclist = Utility.mergeParam(req,design_piclist,"design4");
        design_piclist = Utility.mergeParam(req,design_piclist,"design5");
        design_piclist = Utility.mergeParam(req,design_piclist,"design6");


        //施工图

        var construction_piclist = "";

        construction_piclist = Utility.mergeParam(req,construction_piclist,"construct1");
        construction_piclist = Utility.mergeParam(req,construction_piclist,"construct2");
        construction_piclist = Utility.mergeParam(req,construction_piclist,"construct3");
        construction_piclist = Utility.mergeParam(req,construction_piclist,"construct4");
        construction_piclist = Utility.mergeParam(req,construction_piclist,"construct5");
        construction_piclist = Utility.mergeParam(req,construction_piclist,"construct6");





        var params ={obj_id: req.param("obj_id"),type_name: req.param("type_name"),worker_name: req.param("worker_name"),worker_avatar: req.param("worker_avatar"),
            price: req.param("price"),status: req.param("status"),start_time: req.param("start_time"),
            end_time: req.param("end_time"),publish_time: req.param("publish_time"),address: req.param("address"),
            square: req.param("square"),amount: req.param("amount"),design_piclist: design_piclist,
            construction_piclist:construction_piclist

        };
        params = Utility.get_list_page_size_param(req,params);

        Action.send(req, res,"/workerCaselist/Update",params,function(res,data) {
            res.status(200).json(JSON.parse(data));
        });
    });


    //
    router.all('/workerCaselist/Delete', function (req, res) {

        var params = {obj_id: req.param("obj_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/workerCaselist/Delete", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });


    //列表获取
    router.all('/workerCheckin/getListPaging', function (req, res) {

        var params = {worker_id: req.param("worker_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/workerCheckin/getListPaging", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //删除
    router.all('/workerType/Delete', function (req, res) {

        var params = {obj_id: req.param("obj_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/workerType/Delete", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //列表获取
    router.all('/workerType/getListPaging', function (req, res) {

        var params = {type_id: req.param("type_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/workerType/getListPaging", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });


    //添加
    router.all('/workerType/add', function (req, res) {

        var params = {name: req.param("name")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/workerType/add", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //更新
    router.all('/workerType/update', function (req, res) {

        var params = {name: req.param("name"), obj_id: req.param("obj_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/workerType/update", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //列表获取
    router.all('/workAmount/getList', function (req, res) {

        var params = {mobile: req.param("mobile"),status:req.param("status")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/workAmount/getList", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //列表获取
    router.all('/workAmount/getLogList', function (req, res) {

        var params = {request_id: req.param("request_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/workAmount/getLogList", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //拒绝
    router.all('/workAmount/denyRequest', function (req, res) {

        var params = {reason: req.param("reason"), obj_id: req.param("request_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/workAmount/denyRequest", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });
    //同意
    router.all('/workAmount/acceptRequest', function (req, res) {

        var params = {reason: req.param("reason"), obj_id: req.param("request_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/workAmount/acceptRequest", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //获取现金流水
    router.all('/workAmount/getBankCashList', function (req, res) {

        var params = {worker_id: req.param("worker_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/workAmount/getBankCashList", params, function (res, data) {

            console.log(data);
            res.status(200).json(JSON.parse(data));
        });
    });

    //服务项目

    //添加
    router.all('/worker/addWorkerService', function (req, res) {

        var params = {type_name: " ",type_id: req.param("type_id"),service_name: req.param("service_name")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/worker/addWorkerService", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //删除
    router.all('/worker/deleteWorkerService', function (req, res) {

        var params = {obj_id: req.param("obj_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/worker/deleteWorkerService", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //列表获取
    router.all('/worker/getWorkerServiceListPaging', function (req, res) {

        var params = {type_id: req.param("type_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/worker/getWorkerServiceListPaging", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });
















}
